package ui.skin
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.filters.DropShadowFilter;
	
	public class ComponentSkin implements ISkin
	{
		protected var _skin : MovieClip;
		private var _backGroundSkin : DisplayObject;
		private var usedCount : int;
		
		public function ComponentSkin(skin : *)
		{
			if(skin && skin is Class)
				_skin = new skin();
			else if(skin is MovieClip)
				_skin = skin;
			
			if(( _skin && _skin.backGroundSkin))
			{
				_backGroundSkin = _skin.backGroundSkin as DisplayObject;
			}
		}
		
		/**
		 * 取得背景图
		 * @return
		 */		
		public function getBackGroundSkin() : DisplayObject
		{
			return _backGroundSkin;
		}
		
		/**
		 * 返回当前Ui 
		 * @return
		 */		
		public function getUI():MovieClip
		{
			return _skin;
		}
		
		public function getHasUsed():Boolean
		{
			return false;
		}
		
		public function increaseUsedCount():void
		{
			usedCount ++;
		}
		
		public function copyUI():MovieClip
		{
//			if(_skin)
//				return duplicateDisplayObject(_skin) as MovieClip;
			return null;
		}
		
		public function dispose():void
		{
			_skin = null;
		}
		
		protected function getShadow (dist : Number, knockout : Boolean = false) : DropShadowFilter
		{
			return new DropShadowFilter(dist, 45, 0x00000000, 1, dist, dist, .3, 1, knockout);
		}
		
		public function setBackGroundSkin(value:DisplayObject):void
		{
			_backGroundSkin = value;
		}
		
	}
}